home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 1997
/
HAM Radio 1997.iso
/
vcls
/
formset
/
formset.doc
< prev
next >
Wrap
Text File
|
1996-04-08
|
5KB
|
132 lines
A FormSet is a custom control based on the Delphi TabSet. You can
install it on the tool palette through Options/Install Components on
the Delphi action bar menu. I haven't learned how to write Windows
help yet, so this file is all there is.
FormSet is derived from TabSet. All the properties, methods and events
that are documented for TabSets also work with FormSets. With a TabSet
you probably map each tab to a page in a NoteBook. With a FormSet you
map each tab to a form. We'll call the form that has the FormSet the
Parent or Book form, and the forms displayed with the tabs Child or
Page forms. When you click on a tab, the FormSet displays the Child
form in the client area of the Parent. When you change tabs, the
FormSet can release the old form for best memory use, or leave it in
memory for best performance.
Child or Page forms are as normal as I could make them. Be sure to
define them with Visible as False and BorderStyle anything but bsNone.
If you want dynamically created forms, move them from the AutoCreate
list to the Availble list.
In the designer, you build a FormSet just like a TabSet. You may
specify the tab captions in the Tabs array or add them at runtime
through FormSet.Tabs.Add('Caption').
There is one additional event which you MUST handle. It is called
OnTabLoad. The FormSet calls this event any time a tab is clicked and
the FormSet does not have the Child TForm.
The first parameter for OnTabLoad is the usual Delphi Sender. The
second is the TabIndex of the tab which is being loaded. The third
parameter is an object called TFormTab, defined as follows:
TFormTab = class
Form : TForm;
OnOpen : TFTOpen;
OnClose : TFTClose;
Height : Integer;
Width : Integer;
end;
You must fill the Form property, probably like this:
select case TabIndex
case 0 : TFormTab.Form := TPage1.Create(Self);
case 1 : TFormTab.Form := TPage2.Create(Self);
case 2 : TFormTab.Form := TPage3.Create(Self);
end;
or if you prefer a caption to an index:
Caption := FormSet1.Tabs[TabIndex]
if Caption = 'Home' then FormTab.Form := TPage1.Create(Self);
if Caption = 'Auto' then FormTab.Form := TPage2.Create(Self);
if Caption = 'Life' then FormTab.Form := TPage3.Create(Self);
OnOpen can have one of the following values:
ftoSizePageToBook - Size the Child to match the Parent. This
makes all Child forms the same size for a
smooth appearance. This version uses the
original size of the Parent. If the user
resizes it, FormSet will restore it to the
original size. This may not be good!
ftoSizeBookToPage - Size the Parent to match the Child. This
could be used to accomodate one large Child
without enlarging the Parent all the time.
Not yet implemented correctly.
OnClose can have one of the following values:
ftcAlwaysRelease - Release the form when changing to another tab
ftcNeverRelease - Do not release the form
ftcMaybeRelease - Release the form later if memory runs low
Not yet implemented.
FormSet copys the Height and Width from the child form into the Height
and Width properties the first time through. If your program loads
them with non-zero values, FormSet will use those values.
If you feel the urge to access FormTab objects directly, you can do so
in any part of your code:
var
FormTab : TFormTab;
begin
FormTab := FormSet1.Tabs.Objects[TabIndex];
FormTab.Property := Value;
With a Delphi TabSet, events are triggered in this order:
TabSet.Change
TabSet.Click
If the user clicks on a tab which is already active, neither event is
fired. If the code in onChange sets the AllowChange parameter to
False, the change does not happen and onClick is not fired.
With FormSet, events are triggered as shown below. This sequence may
seem odd until you realize the stages it goes through. First, FormSet
checks to make sure the change is ok with all parties involved:
OldPage.CloseQuery - The old form can abort the change by setting
CanClose to False; none of the other events in the list fire. It
might do this if it has some unfinished business on screen.
NewPage.Create - Done only if the new form has not already been
created. If FormSet.OnTabLoad does not create the new form, FormSet
aborts the change and none of the other events fire.
FormSet.Change - The application can abort the change here by
setting AllowChange to False. None of the other events fire.
Next we close one form and open another:
OldPage.Hide - Always happens. Gives the old page a chance to save
data.
OldPage.Destroy - happens only if the old page has OnClose property
set to fscAlwaysRelease.
NewPage.Show - Always happens. Gives the new page a chance to load
data.
Finally, like the original TabSet control, FormSet fires the Click
event after all the interesting stuff has already happened. The new
page is already visible by this time.
FormSet.Click